package com.educate.controller;

import com.educate.common.dto.VideoFileDto;
import com.educate.service.VideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author yjj
 * @date 2021/12/23
 * @Description  VideoController
 */
@Api(tags = "课程视频相关接口")
@RestController
@RequestMapping("/video")
public class VideoController {

    @Autowired
    private VideoService videoService;

    @ApiOperation("查询该课程对应的所有视频")
    @GetMapping("/{courseId}")
    public List<VideoFileDto> getAllVideos(@PathVariable String courseId){
        return videoService.getAllVideosByCourseId(courseId);
    }

    @ApiOperation("删除视频")
    @DeleteMapping("/{courseId}/{videoId}")
    public String deleteVideo(@PathVariable String courseId, @PathVariable String videoId){
        videoService.deleteVideo(courseId,videoId);
        return "删除成功！";
    }
}
